﻿@model JewererBasic.BO.ComponentHistoryModel
<h2>History</h2>
@using (Html.BeginForm())
{
    <table class="table head">
        <tr>
            <th>Component Id</th>
            <th>From</th>
            <th>To</th>
            <th>Object Export/Import</th>
            <th>Import/Export</th>
        </tr>
        <tr>
            <td>
                @Html.TextBoxFor(m => m.Component_Id, new { @id = "txtComponentId" })
            </td>
            <td>
                @Html.EditorFor(m => m.TimeFrom, new { @id = "txtDateFrom" })
            </td>
            <td>
                @Html.EditorFor(m => m.TimeTo, new { @id = "txtDateTo" })
            </td>
            <td>
                @Html.DropDownListFor(m => m.Kind_Reciever, ViewBag.KindReciever as SelectList)
            </td>
            <td>
                @Html.DropDownListFor(m => m.TypeReport, ViewBag.ListTypeReport as SelectList)
            </td>
        </tr>
    </table>
    <input type="submit" value="VIEW" />
    if (Model.TypeReport.Equals("Export"))
    {
        if (Model.ExportBag != null)
        {
            <p><strong class="myStrongAnnounce">Export Bags</strong></p>
            <table class="table head">
        <tr>
            <th>Number Export</th>
            <th>Bag_Id</th>
            <th>Component Id</th>
            <th>Weight</th>
            <th>Time</th>
            <th>MC</th>
        </tr>
        @foreach (var item in Model.ExportBag)
        {            
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Numb_Export)</td>
                <td>@Html.DisplayFor(modelItem => item.Bag_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Weight)</td>
                <td>@Html.DisplayFor(modelItem => item.Date)</td>
                <td>@Html.DisplayFor(modelItem => item.MC)</td>
            </tr>
        }
    </table>
        }
        if (Model.ExportOrderComponent != null)
        {
            <p>
        <strong class="myStrongAnnounce">Export Component Orders </strong>
    </p>
            <table class="table head">
        <tr>
            <th>Bag Code</th>
            <th>Final Component</th>
            <th>Mix Component</th>
            <th>Weight</th>
            <th>Time</th>
            <th>Worker Id</th>
            <th>MC</th>
        </tr>
        @foreach (var item in Model.ExportOrderComponent)
        {            
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Order_Component_Detail_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Slave_Component_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Main_Component_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Export_Weight)</td>
                <td>@Html.DisplayFor(modelItem => item.Date)</td>
                <td>@Html.DisplayFor(modelItem => item.MC)</td>
            </tr>
        }
    </table>
        }
        if (Model.ExportOrderTree != null)
        {
            <p>
                <strong class="myStrongAnnounce">Export Trees</strong>
            </p>
            <table class="table head">
        <tr>
            <th>Tree Id</th>
            <th>Component Id</th>
            <th>Export Weight</th>
            <th>Time</th>
            <th>MC</th>
            <th>Worker Id</th>
        </tr>
        @foreach (var item in Model.ExportOrderTree)
        {            
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Tree_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Export_Weight)</td>
                <td>@Html.DisplayFor(modelItem => item.Date)</td>
                <td>@Html.DisplayFor(modelItem => item.MC)</td>
                <td>@Html.DisplayFor(modelItem => item.Worker_Id)</td>
            </tr>
        }
    </table>
        }
        if (Model.ExportStaff != null)
        {
            <p>
                <strong class="myStrongAnnounce">Export Staffs</strong>
            </p>
            <table class="table head">
        <tr>
            <th>Numb Export</th>
            <th>Component Id</th>
            <th>Staff Id</th>
            <th>Export Weight</th>
            <th>MC</th>
        </tr>
        @foreach (var item in Model.ExportStaff)
        {            
            <tr>
                <td>@Html.DisplayFor(modelItem => item.Staff_Export_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                <td>@Html.DisplayFor(modelItem => item.Export_Weight)</td>
                <td>@Html.DisplayFor(modelItem => item.Worker_Id)</td>                
                <td>@Html.DisplayFor(modelItem => item.MC)</td>
            </tr>
        }
    </table>
        }
    }
    else
    {
        if (Model.ImportComponent != null)
        {

            <p><strong class="myStrongAnnounce">Import Component</strong></p>
            <table class="table head">
                <tr>
                    <th>Numb Import</th>
                    <th>Component_Id</th>
                    <th>Weight</th>
                    <th>Time</th>
                    <th>MC</th>
                </tr>
                @foreach (var item in Model.ImportComponent)
                {
		            <tr>
                        <td>@Html.DisplayFor(modelItem => item.Id_Import)</td>
                        <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                        <td>@Html.DisplayFor(modelItem => item.Weight)</td>
                        <td>@Html.DisplayFor(modelItem => item.Date)</td>
                        <td>@Html.DisplayFor(modelItem => item.MC)</td>
		            </tr>
                }
            </table>
        }
        if (Model.ImportOrderComponent != null)
        {
            <p><strong class="myStrongAnnounce">Import Order Component</strong></p>
            <table class="table head">
                <tr>
                    <th>Bag Code</th>
                    <th>Component_Id</th>
                    <th>Weight</th>
                    <th>Time</th>
                    <th>MC</th>
                    <th>List Components</th>
                </tr>
                @foreach (var item in Model.ImportOrderComponent)
                {
		            <tr>
                        <td>@Html.DisplayFor(modelItem => item.Bag_Code)</td>
                        <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                        <td>@Html.DisplayFor(modelItem => item.Return_Weight)</td>
                        <td>@Html.DisplayFor(modelItem => item.Date)</td>
                        <td>@Html.DisplayFor(modelItem => item.MC)</td>
                        <td>@Html.DisplayFor(modelItem => item.ListMolecule)</td>
		            </tr>
                }
            </table>
        }
        if (Model.ImportOrderTree != null)
        {
            <p><strong class="myStrongAnnounce">Import Order Tree</strong></p>
            <table class="table head">
                <tr>
                    <th>Tree Id</th>
                    <th>Component_Id</th>
                    <th>Weight</th>
                    <th>Time</th>
                    <th>MC</th>
                </tr>
                @foreach (var item in Model.ImportOrderTree)
                {
		            <tr>
                        <td>@Html.DisplayFor(modelItem => item.Tree_Id)</td>
                        <td>@Html.DisplayFor(modelItem => item.Component_Id)</td>
                        <td>@Html.DisplayFor(modelItem => item.Return_Weight)</td>
                        <td>@Html.DisplayFor(modelItem => item.Date)</td>
                        <td>@Html.DisplayFor(modelItem => item.MC)</td>
		            </tr>
                }
            </table>    
        }
    }
}

@section Scripts{

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="@Url.Content("~/Scripts/json2.min.js")" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {
            $("#txtDateFrom").datepicker();
            $("#txtDateTo").datepicker();
        });

        $("#txtComponentId").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '/Component/GetComponents',
                    data: { query: request.term },
                    dataType: 'json',
                    type: 'GET',
                    success: function (data) {
                        response($.map(data, function (item) {
                            return {
                                label: item,
                                value: item
                            }
                        }));
                    },
                })
            },
            messages: {
                noResults: '',
                results: function () { }
            },
            select: function (event, ui) {
                $("#txtComponentId").val(ui.item.label);
                return false;
            },
            minLength: 1
        });
    </script>
}